package com.markus.code.exam.meituan;

import java.util.Scanner;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/13 10:03
 * todo:
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[][] matrix = new int[n][m];
            for (int i = 0; i < matrix.length; i++) {
                for (int j = 0; j < matrix[i].length; j++) {
                    matrix[i][j] = scanner.nextInt();
                }
            }
            Main demo = new Main();
            demo.process(matrix, n, m);
        }
    }

    private void process(int[][] matrix, int n, int m) {
        int res = n;
        boolean flag = true;
        if (n % 2 == 0) {
            while (flag) {
                if (res == 0) {
                    break;
                }
                int mid = (res - 1) / 2;
                for (int i = 0; i <= mid; i++) {
                    if (!flag) {
                        break;
                    }
                    for (int j = 0; j < m; j++) {
                        if (matrix[mid - i][j] == matrix[mid + i + 1][j]) {
                            continue;
                        } else {
                            flag = false;
                            break;
                        }
                    }
                }
                if (flag) {
                    res = mid;
                }
            }
        }
        for (int i = 0; i <= res; i++) {
            for (int j = 0; j < m; j++) {
                System.out.print(matrix[i][j]);
            }
            System.out.println();
        }
    }
}
